|
|
|
|
|
|
|
To create code for the Click() event, click one of the menu items on your form to display the code window. Lets add code to the form that unloads the form: |
|
|
|
|
| Adding a Click( ) Event to a Menu 1. Open the frmEmployee form. 2. Click() the File, Exit menu item. 3. Type in the following code: | | Private Sub mnuFExit_Click() () Unload Me End Sub |  | It is a good practice to allow the user a couple of different methods to unload a form. In this exercise you use the Unload Me statement in a menus Click() event. |
|
|
|
|
|
|
Adding Code to a Top-level Menu |
|
|
|
|
|
|
|
|
If you have a row of top-level menus, youll normally have drop-down menus under them. If you do have these drop-down menus, you wont be able to write a Click() event for the top-level menus by selecting one and having a code window open up. Instead, youll need to go into a code window, select the menu name from the Object combo box, and then select the Click() event from the Procedure combo box. |
|
|
|
|
|
|
|
|
This will work for any control. Its not necessary to double-click the object from the form. You can always just select the object and the event you want directly from the code window. |
|
|
|
|
|
|
|
|
Besides clicking a menu item with your mouse, you can also generate a menu Click() event using shortcut keys. To add shortcut keys to your menu items, use the Menu Design window to select the menu item. Go to the Shortcut combo box and click the arrow. Youre now shown a list of valid shortcut keys. Select one of these keys; it now becomes a shortcut key that will generate an event. |
|
|
|
|
|